#include <stdlib.h>
#include <iostream>
#include <string>
#include "pawn.h"

Pawn::Pawn(){

}
Pawn::Pawn(bool c, int r, int f){
    color = c;
    rank = r;
    file = f;
}

void Pawn::drawPiece(){
    if(color == WHITE){
        glColor3f(1,1,1);
    }else{
        glColor3f(.1,.1,.1);
    }

    glPushMatrix();
        //Draw the base hemisphere
        glEnable(GL_CLIP_PLANE0);
        double clipEq[] = {0, 1, 0, -0.05};
        glClipPlane(GL_CLIP_PLANE0, clipEq);
        glTranslatef(file-0.5, .01, rank - 0.5);
        glPushMatrix();
        glScalef(1,.5,1);
        glutSolidSphere(.35,20,20);
        glDisable(GL_CLIP_PLANE0);

        //Draw the top of the base
        glTranslatef(0, .3, 0);
        glScalef(1, .5, 1);
        glutSolidSphere(.25, 10, 10);
        glPopMatrix();

        //Draw the column
        glPushMatrix();
        glRotatef(-90, 1, 0, 0);
        gluCylinder(gluNewQuadric(), .2, .12, .7, 10, 10);
        glPopMatrix();

        //Draw the brim
        
        glTranslatef(0, .75, 0);
        glPushMatrix();
        glScalef(1, .3, 1);
        glutSolidSphere(.20, 10, 10);
        glPopMatrix();

        //Draw the top sphere
        glTranslatef(0, .15, 0);
        glutSolidSphere(.2, 10, 10);

    glPopMatrix();
}